var stadiumvalid=null;
$(function () {
    /*给顶部工具条 人员管理 加上激活样式*/
    $("#SubscModule").addClass("active");
    /*根据button上的href属性跳转页面*/
    $("#stadiumNavigation button").click(function (e) {
        try {
            if ($(this).attr("paramType").length > 0) {
                var selectedStadium = $("table").find(".warning");
                if ($(this).attr("paramType") == "id") {
                    window.location.href = "/" + $(this).attr("href") + "?" + $(this).attr("paramName") + "=" + selectedStadium.first().find("td").last().html();
                    return;
                } else if ($(this).attr("paramType") == "ids") {
                    insertMessageBox($("table"), "删除场馆操作是不可逆的，您确认要执行此操作吗？", deleteStadium, $(this));
                    return;
                }
            }
        } catch (e) {
        }
        window.location.href = "/" + $(this).attr("href");
    });

     stadiumvalid = $("#ff").myValid();

 /*   var btnSubmit = $("#ff").find(".controls > button:eq(0)");
    btnSubmit.bind("click", function () {
        iSubmit($("#ff"), $(this), stadiumvalid, null, null, null);
    });*/

    var btnReset = $("#ff").find(".controls > button:eq(1)");
    btnReset.bind("click", function () {
        iReset($("#ff"), $(this), stadiumvalid);
    });

    $("#ff #submit").click(function () {
        var number = 0;
        if (parseInt($("#stadiumNumber").val()) + "" != "NaN") {
            number = parseInt($("#stadiumNumber").val() + "");
        }
        $("#stadiumNumber").val(number);
        window.location.href = $("#ff").attr("action") + "?" + $("#ff").serialize();
    });
    var skip = $("#txtPageSkip").prev();
    skip.bind("click", function () {
        $("#ff #submit").click();
    });


    $('tbody tr').activeTable(
        function () {
            $("#stadiumNavigation button:eq(1)").removeAttr("disabled");
            $("#stadiumNavigation button:eq(2)").removeAttr("disabled");
        },
        function () {
            $("#stadiumNavigation button:eq(1)").attr("disabled", "disabled");
            $("#stadiumNavigation button:eq(2)").attr("disabled", "disabled");
        });
    $(".table-bordered tbody td").fillEmptyCell();
    $("table").trCheckboxToCenter();
    $(".panel").panelBodyToggle();
});
function deleteStadium(obj) {
    var selectedStadium = $("table").find(".warning");
    var ids = [];
    ids[0] = "int";
    selectedStadium.each(function (i) {
        var id = $(this).find("td").last().html();
        ids[++i] = id;
    });
    var data = obj.attr("paramName") + "=" + arrayToJson(ids);
    iAjaxPost(obj.attr("href"), data, function () {
        window.location.href = obj.attr("href2");
    }, $(this), $(".table"));
}